local BaseData = require("data.base.BaseData")
local HeroUnitData = class("HeroUnitData", BaseData)

local schema = {}
schema["id"] = {"number", 0}
schema["base_id"] = {"number", 0}
schema["level"] = {"number", 0}
schema["exp"] = {"number", 0}
schema["magickeyId"] = {"number", 0} --装备法宝
schema["equipmentId"] = {"number", 0} -- 装备
schema["config"] = {"table", {}}
HeroUnitData.schema = schema

function HeroUnitData:ctor()
    HeroUnitData.super.ctor(self)
end

function HeroUnitData:getType()
    return require("utils.TypeHelper").TYPE_HERO
end

function HeroUnitData:getPureParam()
    local param = {}
    param.id = self:getId()
    param.base_id = self:getBase_id()
    param.level = self:getLevel()
    param.exp = self:getExp()
    param.magickeyId= self:getMagickeyId()
    param.equipmentId= self:getEquipmentId()
    return param
end

function HeroUnitData:update(data)
    self:setProperties(data)
    local config = require("config.hero").get(self:getBase_id())
    assert(config, "can not found cfg int hero by id=" .. self:getBase_id())
    self:setConfig(config)
end

function HeroUnitData:isInBattle()
    return G_UserData:getBattle():isInBattleHero(self:getId())
end

function HeroUnitData:getPos()
    return G_UserData:getBattle():getHeroBattlePos(self:getId())
end

function HeroUnitData:getSkills()
    local config = self:getConfig()
    local result = {}
    for i = 1, 3 do
        local skillId = config["skill_id_" .. i]
        table.insert(result, skillId)
    end
    return result
end

return HeroUnitData
